<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <h1>pageA</h1>
  <code id="code"></code>
  <button id="submit">获取自己（A）服务器的数据</button>
  <script>
    document.getElementById('submit').onclick = function () {
      var xhr = new XMLHttpRequest()
      var that = this
      xhr.open('get', 'http://localhost:8000/data')
      xhr.send()
      xhr.onload = function () {
        document.getElementById('code').innerText = this.responseText
      }
    }
  </script>
</body>

</html>